﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Protegidos/Empresas/GENTE_Emp.master" AutoEventWireup="true" CodeFile="edFiscalImpISS.aspx.cs" Inherits="Protegidos_Empresas_Documentos_edFiscalImpISS" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Content ID="Content2" ContentPlaceHolderID="cphSubConteudo" Runat="Server">

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
    var cancelDropDownClosing = false;
    
    function ShowEditForm(id, rowIndex) {
        var grid = $find("<%= RadGrid1.ClientID %>");
        var doc = document.getElementById('<%= hdId.ClientID %>').value;

        var rowControl = grid.get_masterTableView().get_dataItems()[rowIndex].get_element();
        grid.get_masterTableView().selectItem(rowControl, true);

        window.radopen("../_popup/eppUploadOrganDoc.aspx?TipoDocumento=" + doc + "&IdDoc=" + id, "Insert");
        return false;
    }
    
    function ShowInsert() {
        var id = document.getElementById('<%= hdId.ClientID %>').value;
        window.radopen("../_popup/eppUploadOrganDoc.aspx?TipoDocumento=" + id, "Insert");
        return false;
    }
    
    function refreshGrid(arg) {
        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest();
    }

    /* <![CDATA[ */

    function StopPropagation(e) {
        //cancel bubbling
        e.cancelBubble = true;
        if (e.stopPropagation) {
            e.stopPropagation();
        }
    }

    function onDropDownClosing() {
        cancelDropDownClosing = false;
    }

    function onCheckBoxClick(chk) {
        var combo = $find("<%= rcbAno.ClientID %>");
        //prevent second combo from closing
        cancelDropDownClosing = true;
        //holds the text of all checked items
        var text = "";
        //holds the values of all checked items
        var values = "";
        //get the collection of all items
        var items = combo.get_items();

        //enumerate all items
        for (var i = 0; i < items.get_count(); i++) {
            var item = items.getItem(i);
            //get the checkbox element of the current item
            var chk1 = $get(combo.get_id() + "_i" + i + "_chk1");
            if (chk1.checked) {
                text += item.get_text() + ",";
                values += item.get_value() + ",";
            }
        }
        //remove the last comma from the string
        text = removeLastComma(text);
        values = removeLastComma(values);

        if (text.length > 0) {
            //set the text of the combobox
            combo.set_text(text);
        }
        else {
            //all checkboxes are unchecked
            //so reset the controls        
            combo.set_text("")
        }
    }

    //this method removes the ending comma from a string
    function removeLastComma(str) {
        return str.replace(/,$/, "");
    }

    /* ]]> */
</script>
</telerik:RadCodeBlock>

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
<AjaxSettings>
    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
        <UpdatedControls>
            <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
        </UpdatedControls>
        <UpdatedControls>
            <telerik:AjaxUpdatedControl ControlID="rcbAno" LoadingPanelID="RadAjaxLoadingPanel1" />
        </UpdatedControls>
    </telerik:AjaxSetting>      
    <telerik:AjaxSetting AjaxControlID="RadGrid1">
        <UpdatedControls>
            <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
        </UpdatedControls>
    </telerik:AjaxSetting>                                                             
</AjaxSettings>
</telerik:RadAjaxManager>

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Telerik" >
</telerik:RadAjaxLoadingPanel> 

<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
    <Windows>
        <telerik:RadWindow  ID="Insert" runat="server" Title="Upload de arquivo" Height="400px"
            Width="500px" Left="400px" ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true"   />
    </Windows>
</telerik:RadWindowManager>

<table width="99%" align="center">
    <tr>
        <td>
            <div class="Titulo01">ISS</div>
            <div class="Titulo02">Documentos / Fiscal / Impostos</div>
        </td>    
    </tr>
    <tr>
        <td>
        
        <!-- INICIO - Pesquisa -->
        <table width="99%" align="right">
            <tr>
                <td>
                    <div class="SuTituloVR">Dados de Pesquisa</div>
                </td>
            </tr>
            <tr>
                <td>
                    <table>               
                        <tr>
                            <td style="width: 150px"><span class="textoCZ_12">Ano:</span></td>
                            <td>
                                <telerik:RadComboBox ID="rcbAno" runat="server" Skin="Telerik" Font-Names="Verdana"
                                    Width="240px" EmptyMessage="Selecione" AllowCustomText="true" HighlightTemplatedItems="true"
                                    OnClientDropDownClosed="onDropDownClosing">
                                    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
                                    <ItemTemplate>
                                        <div onclick="StopPropagation(event)">
                                            <asp:CheckBox runat="server" ID="chk1" Checked="true" onclick="onCheckBoxClick(this)" />
                                            <asp:Label runat="server" ID="lblDescricao" AssociatedControlID="chk1"><%# Eval("Ano")%></asp:Label>
                                        </div> 
                                    </ItemTemplate>
                                </telerik:RadComboBox>
                                <input runat="server" id="hdId" type="hidden" value="0" />
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td align="right">
                <br />
                    <asp:Button ID="btnPesquisar" runat="server" Text="Pesquisar" Width="110px" onclick="btnPesquisar_Click" />&nbsp;&nbsp;
                    <asp:Button ID="btnIncluir" runat="server" Text="Incluir" Width="110px" OnClientClick="return ShowInsert();" />&nbsp;&nbsp;
                    <asp:Button ID="btnLimpar" runat="server" Text="Limpar" Width="110px" onclick="btnLimpar_Click"/>
                </td>
            </tr>
        </table>
        <!-- FIM - Pesquisa -->
        
        </td>                
    </tr>
    <tr runat="server" id="trResultado">
        <td>
        
            <table width="99%" align="right">
                <tr>
                    <td>
                        <div class="SuTituloVR">Resultado da Pesquisa</div>
                    </td>
                </tr>
                <tr>
                    <td>
                        
                        <!-- INICIO - Resultado -->
                        <telerik:RadGrid ID="RadGrid1" Width="100%" Skin="Telerik" 
                            runat="server" AllowPaging="True" AllowSorting="True"
                            GridLines="None" AutoGenerateColumns="false" PageSize="20" OnItemCreated="RadGrid1_ItemCreated" OnNeedDataSource="RadGrid1_NeedDataSource" OnDeleteCommand="RadGrid1_DeleteCommand" >
                            <MasterTableView GridLines="None" DataKeyNames="IdDocumentoOrganizacao">
                                <Columns>
                                    <telerik:GridBoundColumn UniqueName="Ano" HeaderText="Ano" DataField="Ano" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="Mes" HeaderText="Mes" DataField="Mes" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"></telerik:GridBoundColumn>
                                    <telerik:GridHyperLinkColumn DataTextFormatString="Vizualizar"
                                        DataNavigateUrlFields="Path" UniqueName="Path" DataNavigateUrlFormatString="http://localhost/gentev1/{0}" Target="_blank"
                                        HeaderText="Imagem" DataTextField="Path">
                                    </telerik:GridHyperLinkColumn>
                                    
                                    <telerik:GridTemplateColumn UniqueName="TemplateEditColumn">
                                        <ItemTemplate>
                                            <asp:HyperLink ID="EditLink" runat="server" Text="Editar"></asp:HyperLink>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Remover" CommandName="Delete" ConfirmTitle="Exclusão" ConfirmText="Deseja realmente excluir este Encargo de INSS?" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" HeaderStyle-Width="60px"></telerik:GridButtonColumn>
                                </Columns>
                            </MasterTableView>
                        </telerik:RadGrid>     
                        <!-- FIM - Resultado -->
                        
                    </td>
                </tr>
            </table>
        
        </td>    
    </tr>
</table>

</asp:Content>

